package com.example.demo.controllers;

import com.example.demo.entities.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

@RestController
public class UserController {
    private List<User> users = new ArrayList<User>();

    {
        users.add(new User(1L, "socks", "123456", "127.127.0.1"));
        users.add(new User(2L, "admin", "111111", "192.168.1.1"));
        users.add(new User(3L, "jacks", "222222", null));
    }

    @GetMapping("/")
    public ModelAndView index() {
        return new ModelAndView("pages/user", "users", users);
    }
}
